package com.zhong.gang.applib;


import android.content.Context;
import androidx.annotation.NonNull;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
import com.scwang.smartrefresh.layout.api.RefreshFooter;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.tencent.bugly.Bugly;
import com.tencent.bugly.beta.Beta;
import com.uuzuche.lib_zxing.activity.ZXingLibrary;
import com.zhong.gang.applib.http.OkHttpUtils;
import com.zhong.gang.applib.http.callback.DataBaseBeanCallback;

public abstract class BaseApp extends MultiDexApplication implements DataBaseBeanCallback.LoginOutListener {
    public static Class loginAct = null;
    @Override
    public void onCreate() {
        super.onCreate();
        MultiDex.install(this);
        Beta.autoCheckUpgrade = true;
        Beta.upgradeCheckPeriod = 60 * 1000;
        Beta.showInterruptedStrategy = true;
        Bugly.init(getApplicationContext(), "f0269bc7b8", true);
        loginAct = initLoginAct();
        OkHttpUtils.DEFAULT_MILLISECONDS = 60*1000;
        DataBaseBeanCallback.loginOutListener = this;
        ZXingLibrary.initDisplayOpinion(this);
        SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
            @Override
            public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
                layout.setPrimaryColorsId(R.color.linegray, R.color.gray_2);//全局设置主题颜色
                return new ClassicsHeader(context);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header，默认是 贝塞尔雷达Header
            }
        });

        SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
            @NonNull
            @Override
            public RefreshFooter createRefreshFooter(@NonNull Context context, @NonNull RefreshLayout layout) {
                layout.setPrimaryColorsId(R.color.linegray, R.color.gray_2);//全局设置主题颜色
                return new ClassicsFooter(context);
            }
        });
    }

    public abstract Class initLoginAct();

    public abstract String initBuglyAppId();

}
